import navToNext from '../../../wxjs/navToNext.js';
const app = getApp();

var data = {
  xhx_images: app.xhx_images,
  xhx_route: app.xhx_route,
  activityTypeId: 2, //优惠券类型
};

var currentPage = {
  data,
  onLoad,
  getActivtyAndCoupont,
  onShareAppMessage: function() {
    const that = this;
    const userId = app.userInfo && app.userInfo.userId || "";
    const activityUuid = that.data.activityUuid;
    return {
      title: '',
      path: `${app.xhx_route.leagueList}?invitorUuid=${userId}&activityUuid=${activityUuid}`
    }
  }
};

var page = Object.assign({}, navToNext, currentPage);

Page(page)

function onLoad() {
  const that = this;
  that.getActivtyAndCoupont();
}

function getActivtyAndCoupont() {
  const that = this;
  const activityTypeId = that.data.activityTypeId;
  app.middleware.requestAjax({
    serAddr: app.serAddrs.getActivtyAndCoupont,
    data: {
      activityTypeId,
    },
    cancelToast: true,
    success: function(res) {
      that.setData({
        couponAllGot: res.data.couponAllGot,
        couponOnTheWay: res.data.couponOnTheWay,
        activityUuid: res.data.uuid,
      })
    }
  })
}